package com.hanamaki.operator;

public class Demo01 {
    public static void main(String[] args) {
        // 二元运算

        // 算数运算符
        int a = 10;
        int b = 10;
        int c = 10;
        int d = 40;

        /* jdk 1.8 之前*/
        int money = 1000000000;
        System.out.println(money);
        money = 10_0000_0000;
        System.out.println(money);

        System.out.println(a + b);
        System.out.println(a - b);
        System.out.println(c * d);
        System.out.println(c / (double) d);

        /*求余   模运算*/
        System.out.println(15 % 6);


        System.out.println("========================");
        // 数学运算符
        // ++    --
        // ++ 在后 先赋值 后自增
        // ++ 在前 先自增 后赋值
        int e = 3;
        System.out.println(e);// 3
        int f = e++;
        System.out.println(e);// 4
        System.out.println(f);// 3
        int g = ++e;
        System.out.println(e);// 5
        System.out.println(g);// 5

        // 幂运算
        // 2^4
        System.out.println(Math.pow(2, 4));

//        复合赋值运算符
        int i = 3;
        int sum = 3;
        sum = sum + i;
        sum += i;
        System.out.println(sum);

//        关系运算符
        System.out.println(i > sum); // false
        System.out.println(i < sum);//true
        System.out.println(i >= sum);//false
        System.out.println(i <= sum); //true
        System.out.println(i != sum);//true
        System.out.println(i == sum);//false
        System.out.println(i = sum);

        boolean flag = false;
        System.out.println(flag);
        System.out.println(!flag);

        //逻辑运算符
        boolean flaga = false;
        boolean flagb = true;
        System.out.println(flaga && flagb); //false
        System.out.println(flaga || flagb); //true
        System.out.println(!flagb); //false

        /**
         * 短路运算
         */
        int z = 5;
        boolean flag12 = (z < 4) && (z++ < 4);
        System.out.println(flag12); // false true
        System.out.println(z); //


        int o = 3;
        int oo = 7;
        System.out.println(o);
        System.out.println(oo);

        int ooo = o;
        o = oo;
        oo = ooo;
        System.out.println(o);
        System.out.println(oo);


        // 三元运算符
        /* 如果oo > 100 成立 true 不然 false */
        boolean exp = oo > 100 ? true : false;
        System.out.println(exp);

        // 位操作运算符
        // 0 1 00000000001000000000000
        /*左移  乘2
        * 右移  除2*/
        System.out.println(2 << 3);
        System.out.println(8 >> 2);

        // 从左 到右
        int aaa = 10;
        int bbb = 20;
        aaa += bbb;

        String name = "hanamaki";
        System.out.println(name +":"+ aaa);

        System.out.println("" + aaa + bbb);// 50  3020
        System.out.println(aaa + bbb + "");//50

    }
}
